## Create a dataset of people who share a DA with at least another person

library(here)
library(dplyr)
load(here("Data", "wrkdatOwnMap_new.rda"))

wrkdatOwnMap_new <- droplevels(wrkdatOwnMap_new[!is.na(wrkdatOwnMap_new$vm.community.subj), ])

## How many DAs contain more than 1 person
table(table(wrkdatOwnMap_new$dauid))
#
#    1    2    3    4    5    6    9
# 4616  674  131   20    8    4    1

## Make a dataset containing only people living with at least one other person in same DA.
thedas <- names(table(wrkdatOwnMap_new$dauid)[table(wrkdatOwnMap_new$dauid) > 1])

## Restrict attention to people with valid perceptions of their own drawn maps
sameDAdat <- droplevels(wrkdatOwnMap_new[wrkdatOwnMap_new$dauid %in% thedas, ])

save(sameDAdat, file = here("Data", "sameDAdat.rda"))
